package com.itheima.youdianda.controller;

import cn.hutool.core.convert.Convert;
import com.itheima.youdianda.common.R;
import com.itheima.youdianda.pojo.YddCate;
import com.itheima.youdianda.service.YddCateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ydd_cate")
@Slf4j
public class YddCateController {
    @Autowired
    private YddCateService yddCateService;

    /**
     * 数据详情(回显)
     * @param id
     * @return
     */
    @GetMapping("/rowInfo")
    public R getYddcateById(@RequestParam String id){
        return yddCateService.getYddcateById(id);
    }
    /**
     * 分页条件查询
     */
    @GetMapping("/list")
    public R getYddcatePage(@RequestParam String catename,String page,String limit){

        return yddCateService.getYddcatePage(catename,page,limit);
    }
    /**
     * 删除分类
     */
    @GetMapping("/del")
    public R deleteYddcate(@RequestParam Integer id){
        return yddCateService.deleteYddcate(id);
    }
    /**
     * 修改分类
     */
    @PostMapping("/update")
    public R updateYddcate(@RequestBody YddCate yddCate){
        return yddCateService.updateYddcate(yddCate);
    }
    /**
     * 添加分类
     */
    @PostMapping("/add")
    public R addYddcate(@RequestBody YddCate yddCate){
        return yddCateService.addYddcate(yddCate);
    }
    /**
     * 获取所有分类
     */
    @GetMapping("/all")
    public R getAllYddcate(){
        return yddCateService.getAllYddcate();
    }

}
